//订单确认页面
var basePage = require('../../../common/BasePage');
var area = require('../../../utils/area');
var util = require('../../../utils/util');
Page({
    behaviors: [basePage],
    data: {
        areaList: area.areaList,
		showArea: false,
		weight:"",//重量
		/**请求参数 */
		reqData: {
			province_code: '',
			city_code: '',
			district_code: '',
			province: '',
			city: '',
			district: '',
		}
    },
    onLoad: function (option) {
		
    },
	onChange(e){
		this.setData({
			weight:e.detail
		})
	},
	area_ok(e) {
		console.log("area_ok", e);
		let areaArr = e.detail.values;
		let reqData = this.data.reqData;
		//初始化省市县数据
		reqData.province = areaArr[0].name;
		reqData.province_code = areaArr[0].code;
		reqData.city = areaArr[1].name;
		reqData.city_code = areaArr[1].code;
		reqData.district = areaArr[2].name;
		reqData.district_code = areaArr[2].code;
		this.setData({
			area: reqData.province + reqData.city + reqData.district,
			showArea: false
		})
	},
	submit_click(){
		var param=this.data.reqData
        param.weight=this.data.weight
        param.weight= util.replaceStr(param.weight)
		console.log("提交的数据",param)
		this.request({
		    url: this.data.host + '/home/index/shippingType',
		    data: param,
		    method: "GET",
		}, res => {
		    wx.navigateTo({
		      url: '/pages/logistics/shipping/shipping',
		      success: function (obj) {
		          // 通过eventChannel向被打开页面传送数据
		      
		          obj.eventChannel.emit('wuliu', {
		      		wuliu:res.data.freight_list,
		      		// pack_list:res.data.pack_list
		          })
		      },
		      
		    })
		})
	}
    
})